﻿using CoreApi.Meta;
using CoreService.Models;
using System;
using System.Linq;
using System.Web.Http;

namespace CoreService.Controllers
{
    public abstract class BaseController:ApiController
    {
        protected string[] _appKeys = new string[] { };
        protected ReturnValue CheckAppKey(string key)
        {
            if (key == null || key.Equals(string.Empty)) return new ReturnValue(false,"AppKey.Missing");
            if (!_appKeys.Contains<string>(key)) return new ReturnValue(false,"AppKey.Error");
            return new ReturnValue();
        }

        protected ReturnValue CheckRequest(BaseRequest request)
        {
            return CheckAppKey(request.AppKey);
        }
    }
}